import inquirer from "inquirer";
import { addModule } from "./init-project.js";

export default function (config) {
  inquirer
    .prompt([
      {
        type: "list",
        name: "type",
        message: "请选择当前项目的类型:",
        choices: config.types,
        default: "backend",
      },
    ])
    .then((answers) => {
      if (answers.type == "backend") {
        inquirer
          .prompt([
            {
              type: "checkbox",
              name: "module",
              message: "请选择需要添加的模块:",
              choices: config.modules.filter((it) => it.type === answers.type),
              default: [],
            },
          ])
          .then((answ) => {
            addModule(answ, config);
          });
      }
    });
}
